Skip to content

Conversation

@andrurogerz
Copy link
Contributor

Purpose

This patch prepares the llvm/DebugInfo library for public interface annotations in support of an LLVM Windows DLL (shared library) build, tracked in #109483. The purpose of this patch is to make the upcoming codemod of this library more straight-forward. It is not expected to impact any functionality.

Overview

Adds declarations to the header files for two explicit specialized methods:

  • ContinuationRecordBuilder::writeMemberType
  • SimpleTypeSerializer::serialize

These specializations are already defined the corresponding implementation files:

This patch will not impact functionality, it just ensures they're exposed as part of the public ABI so they can be annotated for export in a subsequent patch.

Background

The LLVM Windows DLL effort is tracked in #109483. Additional context is provided in this discourse.

Validation

Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:

  • Windows with MSVC
  • Windows with Clang
  • Linux with GCC
  • Linux with Clang
  • Darwin with Clang

@andrurogerz andrurogerz marked this pull request as ready for review May 20, 2025 19:20
@llvmbot
Copy link
Member

llvmbot commented May 20, 2025

@llvm/pr-subscribers-debuginfo

Author: Andrew Rogers (andrurogerz)

Changes

Purpose

This patch prepares the llvm/DebugInfo library for public interface annotations in support of an LLVM Windows DLL (shared library) build, tracked in #109483. The purpose of this patch is to make the upcoming codemod of this library more straight-forward. It is not expected to impact any functionality.

Overview

Adds declarations to the header files for two explicit specialized methods:

  • ContinuationRecordBuilder::writeMemberType
  • SimpleTypeSerializer::serialize

These specializations are already defined the corresponding implementation files:

This patch will not impact functionality, it just ensures they're exposed as part of the public ABI so they can be annotated for export in a subsequent patch.

Background

The LLVM Windows DLL effort is tracked in #109483. Additional context is provided in this discourse.

Validation

Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:

  • Windows with MSVC
  • Windows with Clang
  • Linux with GCC
  • Linux with Clang
  • Darwin with Clang

Full diff: https://github.com/llvm/llvm-project/pull/140785.diff

2 Files Affected:

  • (modified) llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h (+14)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h (+13)
diff --git a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
index 84cef520a2f46..fc86a6249aa94 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
@@ -12,6 +12,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/DebugInfo/CodeView/CVRecord.h"
+#include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
 #include "llvm/Support/BinaryByteStream.h"
 #include "llvm/Support/BinaryStreamWriter.h"
@@ -50,6 +51,19 @@ class ContinuationRecordBuilder {
 
   std::vector<CVType> end(TypeIndex Index);
 };
+
+#define TYPE_RECORD(EnumName, EnumVal, Name)
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
+  extern template void ContinuationRecordBuilder::writeMemberType(             \
+      Name##Record &Record);
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS
+
 } // namespace codeview
 } // namespace llvm
 
diff --git a/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h b/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
index fcc0452a6ae9a..2ee815b0e9617 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
@@ -10,6 +10,7 @@
 #define LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include <vector>
 
 namespace llvm {
@@ -32,6 +33,18 @@ class SimpleTypeSerializer {
   ArrayRef<uint8_t> serialize(const FieldListRecord &Record) = delete;
 };
 
+#define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
+  extern template ArrayRef<uint8_t> SimpleTypeSerializer::serialize(           \
+      Name##Record &Record);
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name)
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS
+
 } // end namespace codeview
 } // end namespace llvm
 

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The templates were previously defined, but not necessarily meant for external consumption. Are we sure that these are meant to be exported? I guess the question is, why do these templates have to be exposed? Are users expected to call these low level methods or is it because they are referenced from other symbols?

@andrurogerz
Copy link
Contributor Author

why do these templates have to be exposed?

Yeah, good question. They are only referenced by the unit tests for this library (DebugInfoCodeViewTests). It wasn't needed for Windows DLL, just for so/dylib builds with hidden visibility. But I think I actually have a simpler solution that doesn't require these declarations in the header.

@andrurogerz
Copy link
Contributor Author

Ok, there is a way to solve this one without adding these exports. Closing this out.

@andrurogerz andrurogerz deleted the llvm-debuginfo-templates branch July 23, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants